package com.bookmanagement.controller.user;

import com.bookmanagement.DTO.BorrowDTO;
import com.bookmanagement.result.Result;
import com.bookmanagement.service.BorrowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author skyjay
 */
@RestController
@RequestMapping("/borrow")
public class BorrowController {
    @Autowired
    private BorrowService borrowService;

    @PostMapping("/{id}")
    public Result borrow(@RequestBody BorrowDTO borrowDTO){
        borrowService.borrow(borrowDTO);
        return Result.success();
    }

    @PostMapping("/back/{id}")
    public Result back(@PathVariable("id") Integer id){
        borrowService.back(id);
        return Result.success();
    }
}
